<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/font/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome-ie7.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/Validform/5.3.2/Validform.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/js/jquery-ui-1.10.3.custom.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.ui.touch-punch.min.js}"></script>
    <script th:src="@{/erp/assets/js/ace-elements.min.js}"></script>
    <script th:src="@{/erp/assets/js/ace.min.js}"></script>
    <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>

    <title>采购申请列表</title></head>
<body>

<div class="margin clearfix">
    <div class="stystems_style">
        <div class="tabbable">
            <div class="page-content clearfix">
                <div id="Member_Ratings">
                    <div class="d_Confirm_Order_style">

                    </div>
                    <div class="search_style">
                        <form>
                            <ul class="search_content clearfix">
                                <li><label class="l_f">产品编号</label>
                                    <input name="orderId" id="orderId" type="text" class="text_add" placeholder="产品编号" style=" width:250px" onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"/></li>

                                <li><label class="l_f">产品名称</label>
                                    <input name="pName" id="pName" type="text" class="text_add" placeholder="产品名称" style=" width:250px" onkeyup="value=value.replace(/[^\w\u4E00-\u9FA5]/g, '')"  onafterpaste="this.value=this.value.replace(//[^\w\u4E00-\u9FA5]/g,'')"/>
                                </li>

                                <li><label class="l_f">状态</label>
                                    <select name='orderStatus' style='width:150px' id="orderStatus">
                                        <option value="">请选择订单状态</option>
                                        <option value='1'>已支付</option>
                                        <option value='2'>待发货</option>
                                        <option value='3'>已发货</option>
                                        <option value='4'>已完成</option>
                                    </select></li>
                                <li><label class="l_f">交易时间</label>
                                    <input class="inline laydate-icon" id="dealTime" name="dealTime" style=" margin-left:10px;"></li>

                                <li style="width:90px;">
                                    <button type="button" class="btn_search" id="select"><i class="fa fa-search"></i>查询</button>
                                </li>
                            </ul>
                        </form>
                    </div>

                    <div id="home" class="tab-pane active">
                        <table class="table table-striped table-bordered table-hover" id="sample-table">
                            <thead>
                            <tr>
                                <th width="100">序号</th>
                                <th width="100">订单编号</th>
                                <th width="100">订单类型</th>
                                <th width="110">产品名称</th>
                                <th width="100">产品编号</th>
                                <th width="100">需求数量</th>
                                <th width="100">付款方式</th>
                                <th width="100">交易时间</th>
                                <th width="100">状态</th>
                                <th width="200">操作</th>
                                <th width="100" hidden="hidden">企业ID</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

    <script>
        $(function () {
            var table = $('#sample-table').dataTable({
                "autoWidth":false,
                searching:false,
                serverSide: true,   //开始服务器分页
                aoColumnDefs: [
                    {"orderable": false, "aTargets": [  2, 3, 4,6]}// 制定列不参与排序
                ],
                ajax: {
                    url : '/buy/orderlist',
                    type : 'post',
                    data : function (d) {
                        var data = $('form').serialize();   //获取查询条件

                        //获取分页信息
                        var searchParams= {
                            start : d.start,

                            length : d.length,
                        };
                        data = data + '&' + $.param(searchParams);
                        return data;
                    }
                },
                columns : [
                    { "data":"order.orderId","createdCell": function (td,cellData,rowData,row,col) {
                            $(td).empty().append(row+1);
                        } },
                    { "data":"order.orderId"},
                    { "data": "order.orderType" },
                    { "data": "pname" },
                    { "data": "pnumber" },
                    { "data": "order.number" },
                    { "data":"order.orderId","createdCell": function (td,cellData,rowData,row,col) {
                            $(td).empty().append('<span>线上支付</span>');
                        } },
                    { "data": "order.dealTime" },
                    {"data": "order.orderStatus", "createdCell": function (td, cellData, rowData, row, col) {
                            if (cellData == "1") {
                                $(td).empty().append('<span class="label label-success radius">已支付</span>');
                            } else if (cellData == "2") {
                                $(td).empty().append('<span class="label label-defaunt radius">待发货</span>');
                            } else if (cellData == "3") {
                                $(td).empty().append('<span class="label label-defaunt radius">已发货</span>');
                            } else if (cellData == "4") {
                                $(td).empty().append('<span class="label label-defaunt radius">已完成</span>');
                            }
                        }
                    },
                    { "data":"companyId","createdCell": function (td,cellData,rowData,row,col) {
                            if(rowData.order.orderStatus<3){
                                $(td).empty().append('<a title="查看详情" href="/buy/orderdetial?orderId='+rowData.order.orderId+'" class="btn btn-xs btn-success" ><i class="icon-list bigger-120"></i></a>')
                            }else{
                                $(td).empty().append('<a title="查看详情" href="/buy/orderdetial?orderId='+rowData.order.orderId+'" class="btn btn-xs btn-success" ><i class="icon-list bigger-120"></i></a>\n' +
                                    '<a title="查看物流"  href="/buy/orderWdetial?orderId='+rowData.order.orderId+'"  class="btn btn-xs btn-info" ><i class="bigger-10" style="fout-size:5">查看物流</i></a>')
                            }
                        }
                    },
                    { "data":"companyId", "className" : "hidden"}
                ]
            } );

            //搜索按钮事件
            $('#select').click(function () {
                table.fnUpdate();
            })
        })
        /*时间按钮*/
        laydate.render({
            elem: '#dealTime',
            type: 'datetime'
        });
    </script>
</body>
</html>

